package com.YK.autoconfig;
import com.YK.retryer.beanprocessor.YKRetryBeanProcessor;
import com.YK.retryer.strategy.annotationwrapper.intervalwrapper.impl.ExponentialBackoffRetry;
import com.YK.retryer.strategy.annotationwrapper.intervalwrapper.impl.FixedTimeIntervalRetry;
import com.YK.retryer.strategy.annotationwrapper.intervalwrapper.impl.LinearBackoffRetry;
import com.YK.retryer.strategy.annotationwrapper.resultwrapper.impl.ObjectResultListPredicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @author yuank
 * @version 1.0.0
 * @date 2025/2/25 19:42:36
 */

@Configuration
public class YKRetryAutoConfig {

    /**
     * 重试结果逻辑判断策略组
     */
    @Bean
    @Scope("prototype")  // 指定为原型作用域
    public ObjectResultListPredicate getObjectResultPredicate() {
        return new ObjectResultListPredicate();
    }

    /**
     * 重试时间间隔策略组
     */
    @Bean
    @Scope("prototype")
    public LinearBackoffRetry getLinearBackoffRetry() {
        return new LinearBackoffRetry();
    }
    @Bean
    @Scope("prototype")
    public FixedTimeIntervalRetry getFixedTimeIntervalRetry() {
        return new FixedTimeIntervalRetry();
    }
    @Bean
    @Scope("prototype")
    public ExponentialBackoffRetry getExponentialBackoffRetry() {
        return new ExponentialBackoffRetry();
    }

    /**
     * 包装触发器
     */
    @Bean
    public YKRetryBeanProcessor getYKRetryBeanProcessor() {
        return new YKRetryBeanProcessor();
    }
}